//index.js
//获取应用实例
const app = getApp(),  siteroot = getApp().siteInfo.siteroot;

Page({
  data: {
    banner: {},
    siteName: '',
  },
  
  onLoad: function () {
    var a = this;
    wx.request({
      url: siteroot + 'wxapp/api/index',
      success: function(res) {
        a.setData({
          banner: res.data.banner,
          siteName: res.data.sitename
        }), wx.setNavigationBarTitle({
          title: res.data.sitename,
        })
      }
    });
    // 在页面中定义插屏广告
    let interstitialAd = null;
    if(wx.createInterstitialAd) {
      interstitialAd = wx.createInterstitialAd({
        adUnitId: 'adunit-dbf326b65267c3aa',
      })
      interstitialAd.onLoad((res) => {
        console.log('插屏 广告加载成功')
      });
      interstitialAd.show().catch((err) => {
        console.error(err)
      })
    }
  },
  goSign: function(e) {
    wx.navigateTo({
      url: '/pages/sign/sign',
    })
  },
  duihuan: function() {
    wx.redirectTo({
      url: '/pages/duihuan/duihuan',
    })
  },
  libao: function() {
    wx.redirectTo({
      url: '/pages/libao/libao',
    })
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    return {
      title: this.data.siteName,
      path: '/pages/inde/index'
    }
  }
})
